#!/usr/bin/env python
# -*- coding:utf-8 -*-
# 爬取图片

import requests
import re

if __name__ == "__main__":
    url = "https://www.qiushibaike.com/imgrank/"
    # UA伪装：将对应的User-Agent封装到一个字典中
    headers = {
        'User-Agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Mobile Safari/537.36'
    }

    page_text = requests.get(url=url,headers=headers).text
    print page_text
    # <div class="thumb">
    # <a href="/article/123686944" target="_blank">
    # <img src="//pic.qiushibaike.com/system/pictures/12368/123686944/medium/5M9V152R4V8QDH5D.jpg" alt="糗事#123686944" class="illustration" width="100%" height="auto">
    # </a>
    # </div>
    ex = '<div class="thumb">.*?<img src="(.*?)" alt.*?</div>'
    img_src_list = re.findall(ex,page_text,re.S)

    print img_src_list


